//
//  ZSSecurityUtil.h
//  CheFu365
//
//  Created by safiri on 2017/8/31.
//  Copyright © 2017年 safiri. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@interface ZSSecurityUtil : NSObject

#pragma mark - Encrypt and Decrypt

//MARK: AES
+ (NSString *)encryptAES128ForString:(NSString *)string key:(NSString *)key giv:(NSString *)giv;
+ (NSString *)decryptAES128ForString:(NSString *)string key:(NSString *)key giv:(NSString *)giv;

//MARK: DES
+ (NSString *)encryptDESForString:(NSString *)string key:(NSString *)key gIv:(NSString *)iv;
+ (NSString *)decryptDESForString:(NSString *)string key:(NSString*)key gIv:(NSString *)iv;

//MARK: 3DES
+ (NSString *)encrypt3DESForString:(NSString *)string key:(NSString *)key gIv:(NSString *)iv;
+ (NSString *)decrypt3DESForString:(NSString *)string key:(NSString*)key gIv:(NSString *)iv;

#pragma mark - hash

+ (NSString *)md2ForString:(NSString *)string;
+ (NSString *)md4ForString:(NSString *)string;
+ (NSString *)md5ForString:(NSString *)string;

+ (nullable NSString *)sha1ForString:(NSString *)string;
+ (nullable NSString *)sha224ForString:(NSString *)string;
+ (nullable NSString *)sha256ForString:(NSString *)string;
+ (nullable NSString *)sha384ForString:(NSString *)string;
+ (nullable NSString *)sha512ForString:(NSString *)string;

+ (nullable NSString *)hmacMD5ForString:(NSString *)string withKey:(NSString *)key;
+ (nullable NSString *)hmacSHA1ForString:(NSString *)string withKey:(NSString *)key;
+ (nullable NSString *)hmacSHA224ForString:(NSString *)string withKey:(NSString *)key;
+ (nullable NSString *)hmacSHA256ForString:(NSString *)string withKey:(NSString *)key;
+ (nullable NSString *)hmacSHA384ForString:(NSString *)string withKey:(NSString *)key;
+ (nullable NSString *)hmacSHA512ForString:(NSString *)string withKey:(NSString *)key;

+ (nullable NSString *)crc32ForString:(NSString *)string;

#pragma mark - Encode and Decode

//MARK: 16进制
/// data转为16进制字符串
+ (NSString *)convertDataToHexStr:(NSData *)data;
/// 16进制字符串转为data
+ (NSData *)convertHexStrToData:(NSString *)str;

//MARK: 64进制
+ (NSString *)encodeBase64String:(NSString *)normalString;
+ (NSString *)decodeBase64String:(NSString *)base64String;

@end
NS_ASSUME_NONNULL_END
